<template>
    <div>
        <div>
            <el-form :inline="true" :rules="rules" ref="ruleForm" :model="formInline" label-width="100"  class="demo-form-inline">
                <el-form-item label="AO号" >
                    <el-input size="mini" v-model="formInline.aoCode" placeholder="AO号"></el-input>
                </el-form-item>
                <el-form-item label="图号">
                    <el-input size="mini" v-model="formInline.itemCode" placeholder="图号"></el-input>
                </el-form-item>
                <el-form-item label="质量编号">
                    <el-input size="mini" v-model="formInline.qualityCode" placeholder="质量编号"></el-input>
                </el-form-item>
                <el-form-item label="架次" prop="planeNo">
                    <el-input size="mini" v-model="formInline.planeNo" placeholder="架次"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="mini" @click="doQuery">查询</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <el-table :data="tableData"  size="mini" border style="width: 100%" height="550">
                <el-table-column fixed="left" label="操作" width="100">
                    <template slot-scope="scope">
                        <el-button @click.native.prevent="cancelSort(scope.$index, scope.row)"  type="primary" size="mini">拆包</el-button>
                    </template>
                </el-table-column>
                <el-table-column type="index" label="序号" width="50"></el-table-column>
                <el-table-column prop="aoCode" label="AO号" width="140" show-overflow-tooltip></el-table-column>
                <el-table-column prop="itemCode" label="图号" width="160" show-overflow-tooltip></el-table-column>
                <el-table-column prop="mProductNumber" label="型号" width="120"></el-table-column>
                <el-table-column prop="qualityCode" label="质量编号" width="140" ></el-table-column>
                <el-table-column prop="itemQty" label="需求数量" ></el-table-column>
                <el-table-column prop="matchQty" label="配套数量" ></el-table-column>
                <el-table-column prop="packageCount" label="分拣数量"  ></el-table-column>
                <el-table-column prop="workbinCode" label="箱子号" ></el-table-column>
                <el-table-column prop="toolCode" label="托盘号" ></el-table-column>
                <el-table-column prop="mesCheckQualiticationId" label="合格证号" width="180" ></el-table-column>
                <el-table-column prop="planeNo" label="架次" show-overflow-tooltip></el-table-column>
                <el-table-column prop="wmsItemInventoryId" label="台账ID"  width="160"  show-overflow-tooltip></el-table-column>
                <el-table-column prop="msAoMatchInfoId" label="配套表ID(ms_ao_match_info)" width="240" show-overflow-tooltip></el-table-column>
                <el-table-column prop="msAoMatchBillId" label="物料清单表ID(ms_ao_match_bill)"  width="240"  show-overflow-tooltip></el-table-column>
                <el-table-column prop="msWorkbinMaterialId" label="箱子表主键(ms_workbin_material_id)"  width="240"  show-overflow-tooltip></el-table-column>
                <el-table-column prop="wmsInvOutAllotmentId" label="占用表主键"  width="240"  show-overflow-tooltip></el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange"  @current-change="handleCurrentChange" :current-page.sync="page.currentPage"
                :page-sizes="[20, 200, 300, 400]" :page-size="page.pageSize" layout="total,sizes, prev, pager, next" :total="page.total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import request from "@/utils/request.js";
export default {
    data(){
        return {
            formInline:{aoCode:"",itemCode:"",qualityCode:"",planeNo:""},
            page:{currentPage:1,pageSize:20,total:0},
            tableData:[],
            rules:{
                planeNo:[{ required: true, message: '请输入架次', trigger: 'blur' }]
            }
        }
    },
    methods:{
        handleSizeChange(val){
            this.page.pageSize = val;
            this.doQuery();
        },
        handleCurrentChange(val){
            this.page.currentPage = val;
            this.doQuery();
        },
        doQuery(){
            this.$refs["ruleForm"].validate((valid) => {
                if(!valid){
                    return ;
                }else{
                    request.post("/packageUnpackRest/querySortMaterial",{page:this.page,queryMap:this.formInline}).then((res)=>{
                        this.tableData = res.data.list;
                        this.page.total = res.data.total;
                    });
                }
            })
            
        },
        cancelSort(index,row){
            request.post("/packageUnpackRest/cancelSort",row).then((res)=>{
                if(res.data.retCode=="200"){
                    this.$Alert({title:"失败",type:"success",message:res.data.message});
                }else{
                    this.$Alert({title:"失败",type:"error",message:res.data.message});
                }
                this.$options.methods.doQuery.bind(this)();
            });
        }
    }
}
</script>